package com.springBoot.configer;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;


@SuppressWarnings("deprecation")
@Configuration
public class MyWebMvcConfigurerAdapter extends WebMvcConfigurationSupport {

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
	    // addPathPatterns 用于添加拦截规则
	    // excludePathPatterns 用户排除拦截
//	    registry.addInterceptor(new MyInterceptor()).addPathPatterns("/**").excludePathPatterns("/toLogin","/login");
//	    super.addInterceptors(registry);
	}
	
	@Override
    public void addViewControllers(ViewControllerRegistry registry) {
//        registry.addViewController("/toLogin").setViewName("login");
//        super.addViewControllers(registry);
		System.out.println(123);
		registry.addViewController("/").setViewName("login");
		registry.addViewController("/index.html").setViewName("login");
    }
//	@Bean
//	public WebMvcConfigurationSupport webMvcConfigurerAdapter() {
//		System.out.println(123);
//		WebMvcConfigurationSupport w=new WebMvcConfigurationSupport() {
//			@Override
//			public void addViewControllers(ViewControllerRegistry registry) {
//				System.out.println(123);
//				registry.addViewController("/").setViewName("login");
//				registry.addViewController("/index.html").setViewName("login");
//			}
//		};
//		return w;
//	}
}
